/*
 *  		Usage:
 *  		Create numbered images eg: w01, w02, .. for your walkthrough
 *  		Take this code and replace nrOfWalkthroughPages for a number (int)
 *  		and replace "w0" with the first part of the image name
 *  
 *  
 *  		Intent intent = new Intent(this, WalkthroughActivity.class);
 *			intent.putExtra("nrOfPages", nrOfWalkthroughPages);
 *			intent.putExtra("filePrefix", "w0");
 *   		startActivity(intent);
 */


package com.spacing.app;

import android.content.Intent;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.senseilearning.spanish.R;
import com.viewpagerindicator.PageIndicator;
import com.viewpagerindicator.TitlePageIndicator;
import com.viewpagerindicator.CirclePageIndicator;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

public class WalkthroughActivity extends SherlockFragmentActivity {
	
	ViewPager mPager;
	WalkthroughPagerAdapter mAdapter;
	Intent intent = this.getIntent();
//	PageIndicator mIndicator;
	PageIndicator mIndicator2;
	int totalNrOfPages;
	String filePrefix;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.walkthrough);
		
		
		totalNrOfPages = getIntent().getIntExtra("nrOfPages", 1);
		filePrefix = getIntent().getStringExtra("filePrefix");
		
		mAdapter = new WalkthroughPagerAdapter(getSupportFragmentManager());
		
        mPager = (ViewPager)findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);

        mIndicator2 = (CirclePageIndicator)findViewById(R.id.indicatorCircle);
        
        mIndicator2.setViewPager(mPager);
	
	}
	
	public void walkthroughButtonPress (View view) {
		finish();
	}
	


	class WalkthroughPagerAdapter extends FragmentStatePagerAdapter {
		public WalkthroughPagerAdapter (FragmentManager fm) {
			super(fm);
		}
		
	    @Override
	    public Fragment getItem(int position) {
	        Fragment fragment = new WalkthroughFragment();
	        Bundle args = new Bundle();
	        // Our object is just an integer :-P
	        args.putInt(WalkthroughFragment.ARG_OBJECT, position + 1);
	        args.putInt("nrOfPages", totalNrOfPages);
	        args.putString("filePrefix", filePrefix.toString());
	        fragment.setArguments(args);
	        return fragment;
	    }
	
	    @Override
	    public int getCount() {
	        return totalNrOfPages;
	    }
	
	    @Override
	    public CharSequence getPageTitle(int position) {
	        return "OBJECT " + (position + 1);
	    }
		
	}

}